package cn.com.huak.www.sell.utils;

import cn.com.huak.www.sell.enums.CodeEnum;

/**
 * @author huak@wanggang
 * @date 2019/1/20 17:04
 */
public class EnumUtil {

    /**
     *
     * @return
     */
    public static <T extends CodeEnum> T getByCode(Integer code, Class<T> enumClass){
        for (T each : enumClass.getEnumConstants()){
            if(each.getCode().equals(code)){
                return each;
            }
        }
        return null;
    }
}
